package datas
{
	
	import assists.log.Log;
	
	import main.DataSubBase;
	import main.LocalStoreInfo;
	
	import message.Message;
	import message.NewsRequest;
	import message.NewsResult;
	
	public class NewsData extends DataSubBase
	{
		private var allNewsList:Array;
		private var store:LocalStoreInfo;
		
		private var currentCityId:String;
		
		public function NewsData()
		{
			store = new LocalStoreInfo;
		}
		
		public function getNewsFromServer():void
		{
			currentCityId = data.cityList.chooseCity;
			
			var msg:NewsRequest = new NewsRequest;
			msg.citySign = String(currentCityId);
			
			data.send(msg);
		}
		
		public function changeStore(value:NewsResult):void
		{
			var obj:Object = store.readInfo("news");
			if(obj){
				obj[currentCityId] = value.records;
			}else{
				obj = new Object;
				obj[currentCityId] = value.records;
			}
			
			store.storeInfo("news",obj);
		}		
		
		public function get newsList():Array
		{
			var obj:Object = store.readInfo("news");
			if(obj){
				return obj[currentCityId];
			}
			return [];
		}
	}
}